Program to Display the Table Privileges

import java.sql.*;
public class Sample
{
public static void main(String args[])
{
Connection con=null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:vision","scott","tiger");
Statement st=con.createStatement();
st.executeUpdate(“create table test(eno number(5) primary key,
Na varchar2(20),sal number(5))”);
st.executeUpdate(“insert into test values(100,’prasad’,3430)”);
ResultSet rs=null;
DatabaseMetaData meta=con.getMetaData();
rs=meta.getTablePrivileges(con.getCatalog(),”%”,”TEST”);
while(rs.next())
{
System.out.println(rs.getString("TABLE_CAT"));
System.out.println(rs.getString("TABLE_SCHEM"));
System.out.println(rs.getString("TABLE_PRIVILEGE"));
System.out.println(rs.getString("TABLE_GRANTOR"));
System.out.println(rs.getString("TABLE_GRANTEE"));
System.out.println(rs.getString("TABLE_GRANTABLE"));
}
rs.close();
st.close();
con.close();
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
catch(SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
if(con!=null)
con.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
}